package leetcode.helper;

import leetcode.helper.tree.ListNode;

public class HelpLinkedList {

	public static void printLinkedList(ListNode p) {
		while (p != null) {
			System.out.print(p.val + ",");
			p = p.next;
		}
	}

	public static ListNode array2list(Integer[] array) {
		ListNode head = new ListNode(array[0]);
		int len = array.length;
		ListNode p = head;
		for (int i = 1; i < len; i++) {
			p.next = new ListNode(array[i]);
			p = p.next;
		}
		return head;
	}

	public static ListNode array2list(int[] array) {
		ListNode head = new ListNode(array[0]);
		int len = array.length;
		ListNode p = head;
		for (int i = 1; i < len; i++) {
			p.next = new ListNode(array[i]);
			p = p.next;
		}
		return head;
	}

}
